import _ from 'lodash';
import { connect } from 'umi';
import { useEffect, useMemo, useState } from 'react';
import { Button, Card, Form, Space, Spin, message } from 'antd';
import { SearchOutlined, DiffOutlined, SendOutlined, RollbackOutlined } from '@ant-design/icons';

import { ILoadMapTypeAll } from '@/common';
import ScrollBarLayout from '@/components/ScrollBarLayout';
import { UploadFormCommon } from '@/components/UploadForm';
import { TagSelectNew as TagSelect } from '@/components/TagSelectNew';
import { getPosIDs, getTenantID, getUserID } from '@/utils';
import { DescriptionsType, useDescriptionsType } from '@/components/DescriptionsType';
import { WorkflowChedkRecord, WorkflowHndTaskBtn, WorkflowNoDefaultTable, WorkflowSwitchModal } from '@/components/WorkflowCommonCopy';

import '../common/styles.less';
import { SelectApplyModal } from './SelectApplyModal';
import { OpenDepartmentModal } from './OpenDepartmentModal';
import { RevokeModal } from '../../Acomponents/RevokeModal';
import { SHTH_CHECKSTATE, closeCurrent, renderFileFunc } from '../../Acommon';
import { addExpertsSerivice, editExpertsSerivice, getExpertsSerivice } from '../services';

const UpdateView = ({ curRes, locationProps }) => {
  let { state } = locationProps; /**路由携带参数*/
  let { pageType, record } = state; /**路由携带参数解构*/

  let preflxCls = 'source-bidevaluation'; /**CSS样式*/

  const [isShowApplyModal, setIsShowApplyModal] = useState(false); /**是否显示选择标包弹窗*/
  const [isShowUserModal, setIsShowUserModal] = useState(false); /**是否显示人员弹窗*/

  const [titleFlag, setTitleFlag] = useState(false); /**技术职称是否必填*/
  const [applyObj, setApplyObj] = useState<Record<string, any>>({}); /**保存一份从申请弹窗中选择的/详情返回的申请数据*/
  const [detailInfo, setDetailInfo] = useState<Record<string, any>>({}); /**详情对象*/
  const [invalidState, setInvalidState] = useState<Record<string, any>>({}); /**撤销弹窗*/
  const [sureLoading, setSureLoading] = useState<boolean>(false); /**一个自定义的loading*/

  /**<<<====================工作流使用====================>>>**/
  const flowRequestController = 'purchaseSourceExpertController';
  const flowBusinessType = () => `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_TYPE}1006`;
  const flowOrderType = () => `${getTenantID()}${ILoadMapTypeAll.ALLORDER_TYPE}1016`;
  const flowCategory = () => `${getTenantID()}${ILoadMapTypeAll.EXPERT_CATEGORY}1000`;

  const [isShowWorkRecord, setIsShowWorkRecord] = useState<boolean>(false);
  const [showSwitchFlow, setShowSwitchFlow] = useState<boolean>(false);
  const [workFlowInfoObj, setWorkFlowInfoObj] = useState<Record<string, any>>({
    selectFlowRows: {},
    showWorkFlowModal: false,
    saveNoDefaultFlowID: '',
  });

  /** 处理工作流功能 权限 */
  const workflowPowerAllBtn = useMemo(() => {
    let pownerBtn: Record<string, any> = {
      revokeFlagBtn: false, //撤销按钮
      invalBoolBtn: false, //暂停开始按钮
      stopProcInstBtn: false, //流程作废接口
    };
    if (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1001`) {
      pownerBtn['revokeFlagBtn'] = true;
      pownerBtn['stopProcInstBtn'] = true;
    }

    const taskType: string = flowBusinessType();
    const taskHandInfo: Record<string, any> = detailInfo?.paramObject?.[taskType];
    if (
      taskHandInfo &&
      taskHandInfo?.mactivitiTaskList?.length > 0 &&
      taskHandInfo?.mactivitiTaskList?.[0]?.assigneePositionID == getPosIDs() &&
      taskHandInfo?.mactivitiTaskList?.[0]?.assigneeID == getUserID()
    ) {
      pownerBtn['invalBoolBtn'] = true;
    }
    return pownerBtn;
  }, [detailInfo]);

  /** 关闭切换流程modal方法 */
  const closeSwitchFlowModal = (isDefaultModal: boolean) => {
    if (isDefaultModal) {
      setWorkFlowInfoObj({
        ...workFlowInfoObj,
        showWorkFlowModal: true,
      });
    } else {
      setShowSwitchFlow(false);
    }
  };
  /**<<<====================工作流使用====================>>>**/

  /**表单实例*/
  const [formRef] = Form.useForm();

  /**表单是否可以编辑*/
  const isEditMemo = useMemo(() => {
    // 如果是详情则不显示按钮
    if (pageType == 'detail') return false;
    // 判断数据id是否存在
    if (detailInfo?.id) {
      // 判断state是起草并且checkState不存在
      if (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1000` && !detailInfo?.checkState) {
        // 判断编辑权限
        if (curRes?.['/purchaseSourceExpertController/editRepresentative']) {
          return true;
        }
        // 判断state是起草，checkState是审核退回
      } else if (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1001` && detailInfo?.checkState == SHTH_CHECKSTATE()) {
        // 判断权限 && 数据申请人和申请岗位是不是当前登录人
        if (
          curRes?.['/purchaseSourceExpertController/editRepresentative'] &&
          detailInfo?.applyerID == getUserID() &&
          detailInfo?.applyPositionID == getPosIDs()
        ) {
          return true;
        }
      }
      // 上面判断没有进入的话，就不符合展示的条件
      return false;
    } else {
      // 如果没有id则判断pageType是不是add 和 有没有添加数据的权限
      if (pageType == 'add' && curRes?.['/purchaseSourceExpertController/addRepresentative']) {
        return true;
      }
      // 上面判断没有进入的话，就不符合展示的条件
      return false;
    }
  }, [pageType, detailInfo, curRes]);

  /**表格配置*/
  const [config, methods] = useDescriptionsType({
    name: 'source-experts',
    labelWidth: 240,
    basicForm: formRef,
    schemas: [
      {
        title: '相关采购项目',
        key: 'RelatedProcurementItems',
        fieldChildren: [
          {
            label: '项目编号',
            field: 'purchProjectCode',
            component: 'Input',
            placeholder: isEditMemo ? '请选择' : '--',
            message: '请选择',
            required: true,
            disabled: true,
            contentAfter: isEditMemo ? (
              <a>
                <SearchOutlined onClick={() => setIsShowApplyModal(true)} />
              </a>
            ) : null,
          },
          {
            label: '开标日期',
            field: 'bidOpenTime',
            component: 'Render',
            placeholder: isEditMemo ? '自动带出' : '--',
            disabled: true,
            slotRender(text) {
              return text ? (
                <span style={{ paddingLeft: '5px' }}>{text.split(' ')[0]}</span>
              ) : (
                <span style={{ paddingLeft: '5px', color: '#bfbfbf' }}>自动带出</span>
              );
            },
          },
          {
            label: '项目名称',
            field: 'purchProjectName',
            component: 'Input',
            placeholder: isEditMemo ? '自动带出' : '--',
            colSpan: 2,
            disabled: true,
          },
        ],
      },

      {
        title: '采购人评标代表资格条件',
        key: 'BidEvaluationRepresentative',
        fieldChildren: [
          {
            label: '姓名',
            field: 'fullName',
            component: 'Input',
            required: true,
            colSpan: 1,
            placeholder: isEditMemo ? '请选择' : '--',
            message: '请选择',
            disabled: !isEditMemo,
            contentAfter: isEditMemo ? (
              <a>
                <SearchOutlined onClick={() => setIsShowUserModal(true)} />
              </a>
            ) : null,
          },
          {
            label: '证件号码',
            field: 'cardNum',
            component: 'Input',
            required: true,
            disabled: !isEditMemo,
            colSpan: 1,
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
          },
          {
            label: '工作单位名称',
            field: 'companyName',
            component: 'Input',
            disabled: !isEditMemo,
            required: true,
            colSpan: 2,
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
          },
          {
            label: '现任职务',
            field: 'positionName',
            component: 'Input',
            required: true,
            disabled: !isEditMemo,
            colSpan: 1,
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
          },

          {
            label: '联系电话',
            field: 'phoneMobile',
            component: 'Input',
            required: true,
            disabled: !isEditMemo,
            colSpan: 1,
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
          },

          {
            label: '是否有职称',
            field: 'titleFlag',
            component: 'Render',
            required: true,
            slotRender: (text = '0') => {
              if (isEditMemo) {
                return (
                  <TagSelect
                    colSpan={24}
                    formLabel={''}
                    formName={'titleFlag'}
                    defalultKeys={Number(text)}
                    radioList={[
                      {
                        value: 0,
                        name: '无',
                      },
                      {
                        value: 1,
                        name: '有',
                      },
                    ]}
                    onChange={(val) => {
                      setTitleFlag(Boolean(val));
                    }}
                  />
                );
              }

              if (text == '1') {
                return <span style={{ marginLeft: 8 }}>有</span>;
              } else {
                return <span style={{ marginLeft: 8 }}>无</span>;
              }
            },
          },
          {
            label: '技术职称',
            field: 'titleTech',
            component: 'Input',
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
            required: titleFlag ? true : false,
            disabled: !isEditMemo,
          },

          {
            label: '是否熟悉招标采购有关法规',
            field: 'lawFlag',
            component: 'Render',
            required: true,
            slotRender: (text = '0') => {
              if (isEditMemo) {
                return (
                  <TagSelect
                    colSpan={24}
                    formLabel={''}
                    formName={'lawFlag'}
                    defalultKeys={Number(text)}
                    radioList={[
                      {
                        value: 0,
                        name: '无',
                      },
                      {
                        value: 1,
                        name: '有',
                      },
                    ]}
                  />
                );
              }

              if (text == '1') {
                return <span style={{ marginLeft: 8 }}>有</span>;
              } else {
                return <span style={{ marginLeft: 8 }}>无</span>;
              }
            },
          },
          {
            label: '是否具有同类项目评标经历',
            field: 'experFlag',
            component: 'Render',
            required: true,
            slotRender: (text = '0') => {
              if (isEditMemo) {
                return (
                  <TagSelect
                    colSpan={24}
                    formLabel={''}
                    formName={'experFlag'}
                    defalultKeys={Number(text)}
                    radioList={[
                      {
                        value: 0,
                        name: '无',
                      },
                      {
                        value: 1,
                        name: '有',
                      },
                    ]}
                  />
                );
              }

              if (text == '1') {
                return <span style={{ marginLeft: 8 }}>有</span>;
              } else {
                return <span style={{ marginLeft: 8 }}>无</span>;
              }
            },
          },

          {
            label: '推荐说明',
            field: 'suggestInfo',
            component: 'InputTextArea',
            placeholder: isEditMemo ? '请输入' : '--',
            message: '请输入',
            required: true,
            maxLength: 200,
            allowClear: true,
            autoSize: { minRows: 4, maxRows: 6 },
            showCount: true,
            disabled: !isEditMemo,
            colSpan: 2,
          },
          {
            label: '相关附件',
            field: 'attachURL',
            component: 'Render',
            required: false,
            colSpan: 2,
            slotRender: (text, record) => {
              if (isEditMemo) {
                return (
                  <div>
                    <UploadFormCommon
                      form={formRef}
                      fileFormName={'attachURL'}
                      spanCol={24}
                      inRowProportion={24}
                      name={'attachFile'}
                      required={false}
                      accept={'.doc|.docx'}
                      url={'/purchaseSourceExpertController/uploadFile'}
                      downloadUrl={'/purchaseSourceExpertController/downloadFile'}
                      fileFormDelName={'delFile'}
                      defaultFiles={text}
                      maxFile={1}
                      hintTitle={'且只能上传 1 个！'}
                      fieldBusiPath={'purchase/expert'}
                      delFunc={() => {}}
                    >
                      上传
                    </UploadFormCommon>
                  </div>
                );
              } else {
                return (
                  <span style={{ marginLeft: 8 }}>
                    {renderFileFunc({
                      record: detailInfo,
                      fileName: 'attachURL',
                      downloadAddress: '/purchaseSourceExpertController/downloadFile',
                    })}
                  </span>
                );
              }
            },
          },
        ],
      },
    ],
  });

  /**添加接口*/
  const { addExpertsRun, addExpertsLoading } = addExpertsSerivice((res) => {
    if (res?.msgFlag) {
      message?.success(res?.msg);
      onDetail({ id: res?.obj?.id });
    }
  });

  /**编辑接口*/
  const { editExpertsRun, editExpertsLoading } = editExpertsSerivice((res) => {
    if (res?.msgFlag) {
      message?.success(res?.msg);
      onDetail({ id: res?.obj?.id });
    }
  });

  /**详情接口*/
  const { getExpertsRun, getExpertsLoading, getExpertsReload } = getExpertsSerivice((res) => {
    if (res?.msgFlag) {
      setDetailInfo(res?.obj); //详情存一份
      setTitleFlag(Boolean(res?.obj?.titleFlag)); //保存一个flag
      setApplyObj({
        applyID: res?.obj?.applyID,
        projectID: res?.obj?.projectID,
        projectCode: res?.obj?.projectCode,
        projectName: res?.obj?.projectName,
        projectSum: res?.obj?.projectSum,
        purchProjectName: res?.obj?.purchProjectName,
        purchProjectCode: res?.obj?.purchProjectCode,
      });
      methods?.setFieldsValue(res?.obj); //表单回显
      setSureLoading(false);
    }
  });

  /**提交按钮*/
  const onSubmit = () => {
    if (pageType == 'detail') {
      setWorkFlowInfoObj({
        selectFlowRows: detailInfo,
        showWorkFlowModal: true,
        saveNoDefaultFlowID: '',
      });
      return;
    }
    if (detailInfo?.id) {
      onEdit(true);
    } else {
      onAdd(true);
    }
  };

  /**暂存按钮*/
  const onSave = () => {
    if (detailInfo?.id) {
      onEdit();
    } else {
      onAdd();
    }
  };

  /**添加方法*/
  const onAdd = (flag = false) => {
    methods?.validateFields()?.then(async (res) => {
      let resObj = {
        ...applyObj,
        ...res,
        sourceType: 1, //手动添加的标识
        businessType: flowBusinessType(), //流程类别
        workflowType: flowBusinessType(), //流程类别
        cardType: `${getTenantID()}${ILoadMapTypeAll.EXPERTS_CARD_TYPE}1000`, //身份证类型字典
      };
      await addExpertsRun(resObj).then((res) => {
        if (res?.msgFlag) message?.success(res?.msg);
        if (flag) {
          setWorkFlowInfoObj({
            selectFlowRows: res?.obj,
            showWorkFlowModal: true,
            saveNoDefaultFlowID: '',
          });
        }
      });
    });
  };

  /**编辑方法*/
  const onEdit = (flag = false) => {
    methods?.validateFields()?.then(async (res) => {
      let resObj = {
        ...detailInfo,
        ...applyObj,
        ...res,
      };
      await editExpertsRun(resObj)?.then((res) => {
        // if (res?.msgFlag) message?.success(res?.msg)
        if (flag) {
          setWorkFlowInfoObj({
            selectFlowRows: res?.obj,
            showWorkFlowModal: true,
            saveNoDefaultFlowID: '',
          });
        }
      });
    });
  };

  /**详情方法*/
  const onDetail = (obj) => {
    getExpertsRun(obj);
  };

  /**监听器*/
  useEffect(() => {
    if (pageType == 'detail' || pageType == 'edit') {
      onDetail({ id: record?.id });
    }
  }, [pageType]);

  return (
    <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
      <Card
        title={'采购评标代表'}
        className={preflxCls + '-RootBoxDiv'}
        extra={
          <Space>
            {isEditMemo && (
              <Button
                type="primary"
                // icon={<DiffOutlined />}
                onClick={onSave}
              >
                暂存
              </Button>
            )}

            {((!detailInfo?.id && curRes?.['/purchaseSourceExpertController/startProcess/{starterDeptID}']) ||
              (detailInfo?.id &&
                !detailInfo?.checkState &&
                detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1000` &&
                curRes?.['/purchaseSourceExpertController/startProcess/{starterDeptID}'])) && (
              // pageType != 'detail'&&
              <Button
                type="primary"
                // icon={<SendOutlined />}
                onClick={onSubmit}
              >
                提交
              </Button>
            )}

            {locationProps?.state?.returnPathName && (
              <Button danger onClick={() => closeCurrent(locationProps?.state?.returnPathName)}>
                关闭
              </Button>
            )}
            {/* 工作流 */}
            <WorkflowHndTaskBtn
              flowDetailInfo={detailInfo}
              requestController={flowRequestController}
              reloadCallback={getExpertsReload}
              flowBusinessType={flowBusinessType()}
              applyHeader={'apply'}
              revokeRequestUrl={'/purchaseSourceExpertController/invalid'}
              revokeRequestState={`${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}`}
              isShowRevokeStateList={[`${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1001`]}
              revokeTitle={detailInfo?.purchProjectName}
              revokeSuccessCallback={getExpertsReload}
            />
          </Space>
        }
        actions={[
          <Space>
            {((!detailInfo?.id && curRes?.['/purchaseSourceExpertController/startProcess/{starterDeptID}']) ||
              (detailInfo?.id &&
                !detailInfo?.checkState &&
                detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1000` &&
                curRes?.['/purchaseSourceExpertController/startProcess/{starterDeptID}'])) && (
              // pageType != 'detail'&&
              <Button
                type="primary"
                // icon={<SendOutlined />}
                onClick={onSubmit}
              >
                提交
              </Button>
            )}

            {locationProps?.state?.returnPathName && (
              <Button danger onClick={() => closeCurrent(locationProps?.state?.returnPathName)}>
                关闭
              </Button>
            )}

            {/* 
            {curRes['/purchaseSourceExpertController/invalid'] &&
              detailInfo?.id &&
              detailInfo?.applyerID == getUserID() &&
              detailInfo?.applyPositionID == getPosIDs() &&
              (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1001` ||
                (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1001` && detailInfo?.checkState == SHTH_CHECKSTATE())) && (
                <Button
                  type="primary"
                  danger
                  // icon={<RollbackOutlined />}
                  onClick={() => {
                    setInvalidState({ isShow: true, resObj: detailInfo });
                  }}
                >
                  撤销
                </Button>
              )}
               */}
          </Space>,
        ]}
      >
        <Spin spinning={getExpertsLoading || editExpertsLoading || addExpertsLoading || sureLoading}>
          <ScrollBarLayout>
            <div className={'source-bidevaluation-desc'}>
              <DescriptionsType config={config} />
            </div>
          </ScrollBarLayout>
        </Spin>
      </Card>

      {/* 采购申请选择列表 */}
      {isShowApplyModal && (
        <SelectApplyModal
          curRes={curRes}
          onClose={() => {
            setIsShowApplyModal(false);
          }}
          onSave={(res) => {
            let { id, projectID, projectCode, projectName, projectSum, purchProjectName, purchProjectCode, bidOpenTime } = res?.[0];
            setApplyObj({ applyID: id, projectID, projectCode, projectName, projectSum, purchProjectName, purchProjectCode, bidOpenTime });
            methods?.setFieldsValue({
              purchProjectName,
              purchProjectCode,
              bidOpenTime,
            });
          }}
        />
      )}

      {/* 选择人的弹窗 */}
      {isShowUserModal && (
        <OpenDepartmentModal
          isMaxOrg={true}
          onClose={() => setIsShowUserModal(false)}
          onSubmit={(res) => {
            methods?.setFieldsValue({
              fullName: res?.realName,
              cardNum: res?.cardNum, //证件号码
              companyName: res?.userCompanyName, //工作单位
              positionName: res?.userPositionName, //现任职务
              phoneMobile: res?.phoneMobile,
            });
          }}
        />
      )}

      {/* 工作流-----发起流程审批弹窗 */}
      {workFlowInfoObj?.showWorkFlowModal && (
        <WorkflowSwitchModal
          openVisible={workFlowInfoObj?.showWorkFlowModal}
          businessInfoObj={workFlowInfoObj?.selectFlowRows}
          requestController={flowRequestController}
          orderType={workFlowInfoObj?.selectFlowRows?.orderType || flowOrderType()}
          category={flowBusinessType()}
          businessCategory={flowCategory()}
          selectFlowID={workFlowInfoObj?.saveNoDefaultFlowID}
          reloadInfoCallback={getExpertsReload}
          openFlowChangeModal={setShowSwitchFlow}
          onClose={() => {
            setWorkFlowInfoObj({
              ...workFlowInfoObj,
              showWorkFlowModal: false,
            });
          }}
          onSure={() => {
            setSureLoading(true);
          }}
          replaceStrObj={{
            own: 'apply',
            workflowType: 'category',
          }}
        />
      )}

      {/* 工作流-----审批记录 */}
      {detailInfo?.paramObject?.[flowBusinessType()] && (
        <WorkflowChedkRecord
          curRes={curRes}
          dataDetailInfo={detailInfo}
          flowBusinessType={flowBusinessType()}
          requestController={flowRequestController}
          reloadPageCallback={getExpertsReload} // 刷新方法-详情方法
          revokeStateID={`${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1000`}
          allBtnFuncQuqry={workflowPowerAllBtn}
          tabPaneHeight={0.35}
          isCheckDrawer={true}
          isShowCollapse={isShowWorkRecord}
          changeCollapse={(val) => {
            setIsShowWorkRecord(val);
          }}
          cancelStateId={`${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1003`}
          isSyncArchive={true}
        />
      )}

      {/* 工作流-----挑选流程组件 */}
      {showSwitchFlow && (
        <WorkflowNoDefaultTable
          openVisibleSwitch={showSwitchFlow}
          onCloseSwitch={closeSwitchFlowModal}
          requestController={flowRequestController}
          orderType={workFlowInfoObj?.selectFlowRows?.orderType || flowOrderType()}
          category={flowBusinessType()}
          businessCategory={flowCategory()}
          saveSelectFlowID={(flowId: string) => {
            setWorkFlowInfoObj({
              ...workFlowInfoObj,
              saveNoDefaultFlowID: flowId,
            });
          }}
          selectFlowID={workFlowInfoObj?.saveNoDefaultFlowID}
        />
      )}

      {invalidState?.isShow && (
        <RevokeModal
          resObj={invalidState?.resObj}
          revokeRequestUrl={'/purchaseSourceExpertController/invalid'}
          onClose={() => setInvalidState({})}
          reqBody={{ state: `${getTenantID()}${ILoadMapTypeAll?.EXPERT_BUSINESSTYPE}1000` }}
          modalTip={
            <div style={{ color: '#000' }}>
              确认是否撤销【<span style={{ color: 'red' }}>{invalidState?.resObj?.purchProjectName}</span>】的审核,撤销后可重新提交！
            </div>
          }
          reloadRequest={getExpertsReload}
        />
      )}
    </div>
  );
};

export default connect(({ baseLogin, navTab }: Record<string, any>) => ({
  curRes: baseLogin?.permissions,
  navTab,
}))(UpdateView);

// /** 修改申请是否 意向公开/招标采购代表 */
// const { updateApplyFlagRun, updateApplyFlagLoading } = updateApplyFlagServices((res) => {
//   if (res?.msgFlag) {
//     message.success(res?.msg);
//   } else {
//     message.error(res?.msg);
//   }
// });

// /** 审核中，审核通过/作废 开关 */
// const [isSHTGFlag, setIsSHTGFlag] = useState(false);

// /** 监听数据状态改变，更改状态 */
// useEffect(() => {
//   if (
//     (detailInfo?.state && detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll.EXPERT_BUSINESSTYPE}1001` && detailInfo?.checkState == SHZ_CHECKSTATE()) ||
//     (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll.EXPERT_BUSINESSTYPE}1000` && detailInfo?.checkState == SHTH_CHECKSTATE())
//   ) {
//     setIsSHTGFlag(true);
//   }
//   if (
//     isSHTGFlag &&
//     (detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll.EXPERT_BUSINESSTYPE}1004` ||
//       detailInfo?.state == `${getTenantID()}${ILoadMapTypeAll.EXPERT_BUSINESSTYPE}1003`)
//   ) {
//     // 修改申请状态
//     updateApplyFlagRun({
//       expertID: detailInfo?.id,
//       expertFlag: 0,
//       intentID: null,
//       intentFlag: null,
//     });
//   }
// }, [detailInfo?.state, detailInfo?.checkState]);
